package com.zx.stock.common;

import lombok.Getter;
import lombok.Setter;

public enum ResultEnum {
	
	SUCCESS(0,"成功"),
	FAILED(-1,"失败"),
	
	//http错误
	BAB_REQUEST(400,"请求无效 (Bad request)"),
	HTTP_CONNECT_ERROR(404,"远程服务异常"),
	SYSTEM_ERROR(500,"系统错误"),
	
	//解析
	PARAM_ERROR(1000,"参数不合法"),
	XML_PARSE_ERROR(1001,"xml解析异常"),
    JSON_PARSE_ERROR(1002,"json解析异常"),
	REQUEST_METHOD_NOT_SUPPORTED(1003,"不支持请求方式"),
	CONTENT_TYPE_NOT_SUPPORTED(1004,"不支持媒体类型"),
	REQUEST_EXCEPTION(1005,"请求异常"),
	INVALID_TIMESTAMP_EXPIRED(1006,"过期请求"),
	SIGN_ERROR(1007,"签名验证错误"),
	
	//用户
	ACCOUNT_EXIST(2000,"帐户已存在"),
	ACCOUNT_BALANCE_LACK(2001,"帐户余额不足"),
	FILE_UPLOAD_SIZE_ERROR(2002,"上传文件过大"),

	USER_NOT_EXISTS(2100,"用户不存在"),
	USER_NOT_DOMAIN(2101,"非域用户"),
	USER_FROZEN(2102,"帐户被冻结"),
	USER_DOMAIN_LOGIN_ERROR(2103,"域登录失败"),
	USER_LOGIN_NOT_SUPPORT(2104,"不支持该类型用户登录");


	@Getter
	@Setter
	private int code;

	@Getter
	@Setter
	private String msg;


	private ResultEnum(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}
	
	public static ResultEnum getEnumByCode(int code) {
        for (ResultEnum bt : values()) {
            if (bt.code == code) {
                return bt;
            }
        }
        return null;
    }
}
